import {
  ADD_COUNT,
  ADD_TO_CART,
  CHECK_CLICK,
	CHECK_OFF,
	CHECK_ON
} from "./mutation-types.js"

export default {
  [ADD_COUNT](state, payload){
    // 相同iid.count+1
    payload.count += 1    
    // console.log('+1',state.cartList);
  },
  [ADD_TO_CART](state, payload){
    // 将新数据的count设为1
    payload.check = false
    // 将数据push进去购物车
    state.cartList.push(payload)
    // console.log('++',state.cartList);
  },
  [CHECK_CLICK](state, payload){
    payload.check = !payload.check
  },
	[CHECK_OFF](state){
		state.cartList.forEach(item => item.check = false)
	},
	[CHECK_ON](state){
		state.cartList.forEach(item => item.check = true)
	}
}

